<{include file="app/header.tpl"}>

<form action="/m/order/create/paidByOther" class="order-wrap" method="POST">

    <ul id="buy-goods">
        <{foreach from=$goodsList item="goods"}>
            <li class="order-goods">

                <div class="left"><img class="img" src="<{$goods.thumbsrc}>" align="absmiddle" alt=""></div>
                <div class="middle">

                        <p class="title"><{$goods.name}></p>

                        <p class="prompt"><{if $goods.attr.desc}><{$goods.attr.desc}><{/if}></p>

                        <p class="number">数量：<{$goods.money.quantity}></p>
                </div>
                <div class="bottom">
                    <p id="goods-buy-money">￥<{$goods.money.money/100|@number_format:2}></p>
                </div>
                <input type="hidden" name="goodsId[]" value="<{$goods.id}>">
                <input type="hidden" name="goodsAttrId[]" value="<{$goods.attr.id}>">
                <input type="hidden" name="goodsPrice[]" value="<{$goods.money.price}>">
                <input type="hidden" name="goodsQuantity[]" value="<{$goods.money.quantity}>">

            </li>
        <{/foreach}>
    </ul>


    <div id="buy-address" class="order-accept">
        <h2 class="accept">收货信息</h2>
        <{if $address|@count == 0}>
            <h3 class="address">
                <span><a href="/address/add" style="display: block; color: #000;">请填写收货地址</a></span>
                <em class=rightIcon></em>
            </h3>
        <{else}>
        <ul class="user-address">
            <{foreach from=$address item="addr"}>
            <li>
                <label>
                    <input type="radio" class="radio" name="addressId" value="<{$addr.id}>" <{if $addr.isDefault}>checked="checked"<{/if}>>
                    <span class="user-prompt">
                        <{$addr.userName}> <{$addr.telNumber}> <{$addr.detailInfo}>
                    </span>
                </label>
            </li>
            <{/foreach}>
        </ul>
        <{/if}>
    </div>

    <div class="order-invoice" id="buy-invoice">
        <h2 class="pay">发票</h2>
        <div class="order-invoiceType">
            <label>发票类型</label>
            <select name="invoiceType">
                <{foreach from=$invoice.invoiceType key="iValue" item="iName"}>
                <option value="<{$iValue}>"><{$iName}></option>
                <{/foreach}>
            </select>
        </div>

        <div class="order-invoiceContent">
            <label>发票内容</label>
            <select name="invoiceContent">
                <{foreach from=$invoice.invoiceContent key="iValue" item="iName"}>
                <option value="<{$iValue}>" ><{$iName}></option>
                <{/foreach}>
            </select>
        </div>

        <div class="order-invoiceTitle">
            <label>发票抬头</label>
            <input type="text" class="prompt" placeholder="请输入具体信息" name="invoiceTitle" value="">
        </div>
    </div>

    <div id="buy-tickets">
        <input type="text" name="comments" class="order-user-notes" placeholder="用户备注">
    </div>

    <div id="buy-deliver">
        <div class="order-kuaidi">
            <h3 class="manner">快递方式</h3>
            <ul class="user-kuaidi">
            <{foreach from=$deliver item="p"}>
                <li>
                <label>
                    <input class="radio" type="radio" name="deliverId" value="<{$p.id}>" money="<{$p.goodsDeliverMoney}>">
                    <span class="kuaidi-prompt"> <{$p.name}>
                        (默认运费: ￥<{$p.ltMoneyFee/100|number_format:2}>
                        /
                        购买超过<{$p.money/100|number_format:2}>元商品运费￥<{$p.egtMoneyFee/100|number_format:2}>)
                    </span>
                </label>
                </li>
            <{/foreach}>
            </ul>
        </div>
    </div>

    <div class="order-fee-details">
        <h2 class="detail"><span class="rmb">￥</span>费用详情</h2>
        <p class="line fix"><span class="left">商品总金额：</span><span class="right">￥<{$money.total/100|@number_format:2}></span></p>
        <p class="line fix"><span class="left">快递</span><span class="right deliverMoney">￥+0.00</span></p>
       <input type="submit" class="submitBtn" onclick="return submit_buy_now();" name="submit_op" value="提交">
    </div>

</form>

<script>

    function submit_buy_now() {

        if (!<{$address|@count}>) {
            alert('请填写收货地址');
            return false;
        }

        var oRadioVal = $('input:radio[name="addressId"]:checked').val();
        if (!oRadioVal) {
            alert('请选择收货地址');
            return false;
        }
    }

    // 发票动作响应(重置发票组得状态)
    function invoice_reset_stats ()
    {
        var iType = $('select[name="invoiceType"]').val();
        if (iType <= 0)
        {
            $('.order-invoiceContent').hide();
            $('.order-invoiceTitle').hide();
        }
        else
        {
            $('.order-invoiceContent').show();
            $('.order-invoiceTitle').show();
        }
    }

    function deliver_config_changed (item)
    {
        var money = parseInt($(item).attr('money')) / 100;
        $('.deliverMoney').html('￥+' + money);
    }

    $(document).ready(function () {

        // 发票动作响应
        invoice_reset_stats ();
        $('select[name="invoiceType"]').change(invoice_reset_stats);

        // 快递动作响应
        $('input[name="deliverId"]').click(function () {
            deliver_config_changed(this);
        });
        var dItem = $('input[name="deliverId"]').get(0);
        $(dItem).attr('checked', 'checked');
        deliver_config_changed(dItem);
    });

</script>

<{include file="app/footer.tpl"}>
